{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0876c91e",
   "metadata": {},
   "source": [
    "# 第8周\n",
    "* author:邱星倩\n",
    "* time：第8周周二上午\n",
    "* link: [地理/逆地理代码](https://lbs.amap.com/api/webservice/guide/api/georegeo)\n",
    "* link: [POI2.0](https://lbs.amap.com/api/webservice/guide/api/newpoisearch#t7)    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4fe7644",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9bc58ad",
   "metadata": {},
   "source": [
    "# 1.web服务API简介"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a55cbe45",
   "metadata": {},
   "source": [
    "* 高德Web服务API向开发者提供HTTP接口，开发者可通过这些接口使用各类型的地理数据服务，返回结果支持JSON和XML格式。Web服务API对所有用户开放。使用本组服务之前，需要申请应用Key。不同类型用户可获取不同的数据访问能力。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3200d07",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06cc1da2",
   "metadata": {},
   "source": [
    "# 2.地理/逆地理编码"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9eec2c04",
   "metadata": {},
   "source": [
    "* 结构化地址:\n",
    "> 首先，地址肯定是一串字符，内含国家、省份、城市、区县、城镇、乡村、街道、门牌号码、屋邨、大厦等建筑物名称。按照由大区域名称到小区域名称组合在一起的字符。一个有效的地址应该是独一无二的。注意：针对大陆、港、澳地区的地理编码转换时可以将国家信息选择性的忽略，但省、市、城镇等级别的地址构成是不能忽略的。暂时不支持返回台湾省的详细地址信息。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c11c129",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12d3dbda",
   "metadata": {},
   "source": [
    "* 结构化地址-----经纬度\n",
    "> 地理编码/逆地理编码 API 是通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化的能力"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c02eb7f8",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94d17210",
   "metadata": {},
   "source": [
    "## 2.1地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7c0e54c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1）调用requests模块（相对应打开谷歌浏览器）\n",
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ec91f986",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2）请求方法:GET\n",
    "# 3）地理编码 API 服务地址URL：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = 'https://restapi.amap.com/v3/geocode/geo?parameters'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "19561574",
   "metadata": {},
   "outputs": [],
   "source": [
    "api_key = 'web_s'\n",
    "api_s = 'f3a907403f1a05c5629a2662624b7391'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d20f45a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 4）请求的参数 （payload）\n",
    "\n",
    "payload = {\n",
    "    'key' : api_s,\n",
    "    'address' : \"广东省广州市从化区广州南方学院\"\n",
    "}\n",
    "\n",
    "r = requests.get(url=geo_url,params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "146975d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9edd07f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省广州市从化区温泉镇中心大学南方学院',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '020',\n",
       "   'city': '广州市',\n",
       "   'district': '从化区',\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '440117',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.678280,23.628439',\n",
       "   'level': '兴趣点'}]}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "69b22c78",
   "metadata": {},
   "outputs": [],
   "source": [
    "locate = r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "111856f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "location = locate['geocodes'][0]['location']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb4f3612",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "806f3ef2",
   "metadata": {},
   "source": [
    "## 2.2 逆地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a625c0fb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# extensions=base（默认）\n",
    "# 1. 调用requests模块\n",
    "import requests\n",
    "\n",
    "# 2. 请求方法 ： GET\n",
    "\n",
    "# 3. URL地址 \n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\" : f3a907403f1a05c5629a2662624b7391,\n",
    "    \"location\" : location\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "242134f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "bd9d378a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'regeocode': {'addressComponent': {'city': '广州市',\n",
       "   'province': '广东省',\n",
       "   'adcode': '440117',\n",
       "   'district': '从化区',\n",
       "   'towncode': '440117100000',\n",
       "   'streetNumber': {'number': '24号',\n",
       "    'location': '113.677267,23.629149',\n",
       "    'direction': '西北',\n",
       "    'distance': '129.943',\n",
       "    'street': '博学路'},\n",
       "   'country': '中国',\n",
       "   'township': '温泉镇',\n",
       "   'businessAreas': [[]],\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'citycode': '020'},\n",
       "  'formatted_address': '广东省广州市从化区温泉镇博学路广州南方学院'},\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000'}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f02f8a6e",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e362f6c8",
   "metadata": {},
   "source": [
    "### 逆地理代码的参数：poitype：返回附近POI类型\n",
    "> 内容需要 extensions 参数为 all 时才生效。  \n",
    "> 逆地理编码在进行坐标解析之后不仅可以返回地址描述，也可以返回经纬度附近符合限定要求的POI内容。  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "6d89e0e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块（google chrome 浏览器）\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"location\": location,\n",
    "    \"extensions\":\"all\",\n",
    "    \"poitype\":\"true\",\n",
    "    \n",
    "    \n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5cdb113a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8562b68c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'regeocode': {'formatted_address': '广东省广州市从化区温泉镇博学路广州南方学院',\n",
       "  'addressComponent': {'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'city': '广州市',\n",
       "   'citycode': '020',\n",
       "   'district': '从化区',\n",
       "   'adcode': '440117',\n",
       "   'township': '温泉镇',\n",
       "   'towncode': '440117100000',\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'streetNumber': {'street': '博学路',\n",
       "    'number': '24号',\n",
       "    'location': '113.677267,23.629149',\n",
       "    'direction': '西北',\n",
       "    'distance': '129.943'},\n",
       "   'businessAreas': [[]]},\n",
       "  'pois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': '020-87828988;020-61787331',\n",
       "    'direction': '北',\n",
       "    'distance': '470.792',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFG4TAF2',\n",
       "    'name': '广州南方公寓',\n",
       "    'type': '商务住宅;商务住宅相关;商务住宅相关',\n",
       "    'tel': '13622768437',\n",
       "    'direction': '东南',\n",
       "    'distance': '102.617',\n",
       "    'location': '113.678983,23.627778',\n",
       "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       "    'poiweight': '0.237309',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H6FA18J5',\n",
       "    'name': '保利半山花园',\n",
       "    'type': '商务住宅;住宅区;住宅区',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '139.054',\n",
       "    'location': '113.679358,23.627672',\n",
       "    'address': '从莞深高速(广州南方学院南侧)',\n",
       "    'poiweight': '0.223065',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B00140TWHT',\n",
       "    'name': '教工住宅1号',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '222.658',\n",
       "    'location': '113.678490,23.630432',\n",
       "    'address': '笃行路2',\n",
       "    'poiweight': '0.157653',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHRJDM9',\n",
       "    'name': '中南公寓',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': '13711245345',\n",
       "    'direction': '东南',\n",
       "    'distance': '231.223',\n",
       "    'location': '113.680340,23.627566',\n",
       "    'address': '中大南方学院南门1号',\n",
       "    'poiweight': '0.256152',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD588HJ',\n",
       "    'name': '广州南方学院教学楼4号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '242.901',\n",
       "    'location': '113.677460,23.630490',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHZH0IK',\n",
       "    'name': '地下铁',\n",
       "    'type': '餐饮服务;冷饮店;冷饮店',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '74.1376',\n",
       "    'location': '113.677941,23.629029',\n",
       "    'address': '博学路广州南方学院综合楼内',\n",
       "    'poiweight': '0.17934',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU76L2',\n",
       "    'name': '广州南方学院2号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '280.003',\n",
       "    'location': '113.678211,23.630956',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP838K',\n",
       "    'name': '教学楼3号(外国语学院)',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '298.093',\n",
       "    'location': '113.677247,23.630947',\n",
       "    'address': '博学路25',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKSF1FI',\n",
       "    'name': '香辣螺蛳粉',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': '17820061022',\n",
       "    'direction': '西',\n",
       "    'distance': '209.206',\n",
       "    'location': '113.676231,23.628565',\n",
       "    'address': '广州南方学院西4123',\n",
       "    'poiweight': '0.209252',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU8NLD',\n",
       "    'name': '广州南方学院1号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '326.007',\n",
       "    'location': '113.678215,23.631370',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFLF90I2',\n",
       "    'name': '煌上煌酱鸭(南方学院店)',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅',\n",
       "    'tel': '13712317721',\n",
       "    'direction': '东北',\n",
       "    'distance': '256.772',\n",
       "    'location': '113.679965,23.630156',\n",
       "    'address': '笃行路20、22、24号广州南方学院商业中心1层1F015',\n",
       "    'poiweight': '0.209448',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58UTU',\n",
       "    'name': '广州南方学院2号教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '346.352',\n",
       "    'location': '113.677060,23.631346',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H25SMRKP',\n",
       "    'name': '广州南方学院大礼堂',\n",
       "    'type': '科教文化服务;会展中心;会展中心',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '386.65',\n",
       "    'location': '113.680076,23.631502',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.261624',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JD',\n",
       "    'name': '广州南方学院教学楼1号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '391.548',\n",
       "    'location': '113.677077,23.631783',\n",
       "    'address': '博学路19号',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD592BJ',\n",
       "    'name': '广州南方学院综合楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '392.731',\n",
       "    'location': '113.680117,23.631544',\n",
       "    'address': '温泉大道886号广州南方学院内',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP81F0',\n",
       "    'name': '教学楼1号(文学与传媒学院)',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '393.93',\n",
       "    'location': '113.676866,23.631736',\n",
       "    'address': '博学路19号附近',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFLBEOND',\n",
       "    'name': '聚贤楼10号',\n",
       "    'type': '商务住宅;住宅区;宿舍',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '418.51',\n",
       "    'location': '113.681253,23.631036',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.190963',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFH6K3U9',\n",
       "    'name': '广州中大南方招待所',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '020-61787222',\n",
       "    'direction': '西北',\n",
       "    'distance': '378.102',\n",
       "    'location': '113.676330,23.631332',\n",
       "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
       "    'poiweight': '0.254885',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '446.366',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKUVYWV',\n",
       "    'name': '广州和风庭阿七度假别墅',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '424.35',\n",
       "    'location': '113.681736,23.630569',\n",
       "    'address': '保利桃花源',\n",
       "    'poiweight': '0.273168',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'type': '科教文化服务;图书馆;图书馆',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'direction': '北',\n",
       "    'distance': '489.331',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JC',\n",
       "    'name': '广州南方学院4号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '498.883',\n",
       "    'location': '113.679963,23.632652',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFL7C054',\n",
       "    'name': '广州U优森特酒店',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '15813395296',\n",
       "    'direction': '北',\n",
       "    'distance': '464.819',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "    'poiweight': '0.317505',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFG8CSEK',\n",
       "    'name': 'L5员工宿舍',\n",
       "    'type': '商务住宅;住宅区;宿舍',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '554.129',\n",
       "    'location': '113.682583,23.631487',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.185371',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58FR2',\n",
       "    'name': '广州南方学院教学楼9号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '532.163',\n",
       "    'location': '113.679747,23.633032',\n",
       "    'address': '广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HG5Z9JNK',\n",
       "    'name': '广州南方学院教学楼7号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '544.868',\n",
       "    'location': '113.678600,23.633330',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221553',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD599JM',\n",
       "    'name': '广州南方学院第11教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '556.036',\n",
       "    'location': '113.680037,23.633173',\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0GUJYPEG2',\n",
       "    'name': '怒烤烤串(从化店)',\n",
       "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '510.112',\n",
       "    'location': '113.677160,23.632910',\n",
       "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
       "    'poiweight': '0.216026',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU6Z41',\n",
       "    'name': '广州南方学院教学楼6号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '586.331',\n",
       "    'location': '113.678424,23.633710',\n",
       "    'address': '温泉大道882',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []}],\n",
       "  'roads': [{'id': '020F49F0050461206',\n",
       "    'name': '博学路',\n",
       "    'direction': '北',\n",
       "    'distance': '7.63232',\n",
       "    'location': '113.678,23.6284'},\n",
       "   {'id': '020F49F0050462229',\n",
       "    'name': '老虎形街',\n",
       "    'direction': '北',\n",
       "    'distance': '445.159',\n",
       "    'location': '113.679,23.6245'},\n",
       "   {'id': '020F49F0050462451',\n",
       "    'name': '中山路',\n",
       "    'direction': '南',\n",
       "    'distance': '708.299',\n",
       "    'location': '113.677,23.6347'}],\n",
       "  'roadinters': [{'direction': '南',\n",
       "    'distance': '708.299',\n",
       "    'location': '113.676794,23.634661',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'first_name': '博学路',\n",
       "    'second_id': '020F49F0050462451',\n",
       "    'second_name': '中山路'}],\n",
       "  'aois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'adcode': '440117',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'area': '528560.656426',\n",
       "    'distance': '0',\n",
       "    'type': '141201'}]}}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c01488f",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c6383f5",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab5aad13",
   "metadata": {},
   "source": [
    "# 3.作业"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "792373f9",
   "metadata": {},
   "source": [
    "> 1.尝试搜索POI2.0 接口  \n",
    "> 2.获取中餐厅、西餐厅、快餐厅的信息(图片、内容等)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ba22eb0",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df8150bd",
   "metadata": {},
   "source": [
    "### 查询地理代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b085e38c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块-地理代码\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"address\":\"广东省广州市越秀区北京路\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=geo_url, params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "88c4d766",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "36e47bd6",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省广州市越秀区北京路',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '020',\n",
       "   'city': '广州市',\n",
       "   'district': '越秀区',\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '440104',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.267923,23.121253',\n",
       "   'level': '道路'}]}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "40c01785",
   "metadata": {},
   "outputs": [],
   "source": [
    "location = r.json()['geocodes'][0]['location']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35317d07",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd9c445d",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d3843b2",
   "metadata": {},
   "source": [
    "## 3.1 周边搜索——中餐厅"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "186fece4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块---周边搜索\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v5/place/around?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v5/place/around?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"location\" : location,\n",
    "    \"show_fields\" : \"photos\",\n",
    "    \"types\": '050100'\n",
    "    \n",
    "    \n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "6ffa1c11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "cd2a29d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'name': '阿婆牛杂(惠福东店)',\n",
       "   'id': 'B0H1LSGKB1',\n",
       "   'location': '113.267923,23.121257',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路564号101部位',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '五月的沙枣花抓饭(双河)店',\n",
       "   'id': 'B0HKLHRT20',\n",
       "   'location': '113.268003,23.121231',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路568号(近北京路)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '孖记一九九八(北京路店)',\n",
       "   'id': 'B0G2GMLXP4',\n",
       "   'location': '113.267904,23.121165',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路清源巷12号首、二层',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '李喜欢手工虾滑',\n",
       "   'id': 'B0HRP55982',\n",
       "   'location': '113.267803,23.121230',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路惠福东路570号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/89370c65ddd4be7f793a5dd543215649'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/5be805b5159ba3c35bc4f7a5b7fa2e87'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/f74aaff3fcf87764dff4077756100627'}]},\n",
       "  {'name': '牛骨牛杂屋',\n",
       "   'id': 'B0IGC7CRSP',\n",
       "   'location': '113.267878,23.121375',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '步行街与惠新西街交叉口东北20米',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '牛小灶牛杂煲(北京路店)',\n",
       "   'id': 'B0FFIS19MZ',\n",
       "   'location': '113.268071,23.121263',\n",
       "   'type': '餐饮服务;中餐厅;火锅店',\n",
       "   'typecode': '050117',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路步行街惠福东美食街惠福东路586号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/7f5802df6d7bc84d151af4a0f7780bb2'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/03d622818b4bf58e80d6f33f2e83b799'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/0ad74b46b30c49c4ab3e2e063e782a5e'}]},\n",
       "  {'name': '火鳳祥鮮貨火锅商行(北京路店)',\n",
       "   'id': 'B0GK4AM0T3',\n",
       "   'location': '113.268012,23.121408',\n",
       "   'type': '餐饮服务;中餐厅;火锅店',\n",
       "   'typecode': '050117',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路576号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/81d9e56582bc23743545b33dbe7952ba'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/04282e4c75ae9edd70509fd6f1feeaff'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/0e61a1e1746dbb33f57808041ae4e298'}]},\n",
       "  {'name': '蚝魁·高压锅生蚝·海鲜专门店',\n",
       "   'id': 'B0GKJAX5B6',\n",
       "   'location': '113.268073,23.121416',\n",
       "   'type': '餐饮服务;中餐厅;海鲜酒楼',\n",
       "   'typecode': '050119',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路515号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/712806184fc1d924aa2b3dbac6ebe9df'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/e6743d81fb3edbec5e15c8d1cf34e5f9'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/a7711b61aed535a71d00a66ac4e2c40e'}]},\n",
       "  {'name': '其美潮州鱼旦粉世家(惠福东分店)',\n",
       "   'id': 'B00141L0Z3',\n",
       "   'location': '113.267760,23.121435',\n",
       "   'type': '餐饮服务;中餐厅;潮州菜',\n",
       "   'typecode': '050123',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路515号(近光明广场)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/b42099e8059d20e2a56858b37963da0c'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/28d27e98222f4df691aeca89d2f9c4b6'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/2b8b09fabb7b3f1d6368e8a3226bab51'}]},\n",
       "  {'name': '捞起鲜食凉拌(北京路店)',\n",
       "   'id': 'B0HGCOILN7',\n",
       "   'location': '113.268102,23.121433',\n",
       "   'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "   'typecode': '050118',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路525号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/e8deee912bcd9454d9aeccc79668c7e2'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/28067737ccd44a23660008b25a565c05'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/384c0e923e7948dfc63289f26b3fbf9c'}]}],\n",
       " 'count': '10'}"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "012f7f35",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "2345242f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>address</th>\n",
       "      <th>pcode</th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>photos</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>阿婆牛杂(惠福东店)</td>\n",
       "      <td>B0H1LSGKB1</td>\n",
       "      <td>113.267923,23.121257</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>050100</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路564号101部位</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>五月的沙枣花抓饭(双河)店</td>\n",
       "      <td>B0HKLHRT20</td>\n",
       "      <td>113.268003,23.121231</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>050100</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路568号(近北京路)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>孖记一九九八(北京路店)</td>\n",
       "      <td>B0G2GMLXP4</td>\n",
       "      <td>113.267904,23.121165</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>050100</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路清源巷12号首、二层</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>李喜欢手工虾滑</td>\n",
       "      <td>B0HRP55982</td>\n",
       "      <td>113.267803,23.121230</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>050100</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路惠福东路570号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>牛骨牛杂屋</td>\n",
       "      <td>B0IGC7CRSP</td>\n",
       "      <td>113.267878,23.121375</td>\n",
       "      <td>餐饮服务;中餐厅;中餐厅</td>\n",
       "      <td>050100</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>步行街与惠新西街交叉口东北20米</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>牛小灶牛杂煲(北京路店)</td>\n",
       "      <td>B0FFIS19MZ</td>\n",
       "      <td>113.268071,23.121263</td>\n",
       "      <td>餐饮服务;中餐厅;火锅店</td>\n",
       "      <td>050117</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路步行街惠福东美食街惠福东路586号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>火鳳祥鮮貨火锅商行(北京路店)</td>\n",
       "      <td>B0GK4AM0T3</td>\n",
       "      <td>113.268012,23.121408</td>\n",
       "      <td>餐饮服务;中餐厅;火锅店</td>\n",
       "      <td>050117</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路576号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>蚝魁·高压锅生蚝·海鲜专门店</td>\n",
       "      <td>B0GKJAX5B6</td>\n",
       "      <td>113.268073,23.121416</td>\n",
       "      <td>餐饮服务;中餐厅;海鲜酒楼</td>\n",
       "      <td>050119</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路515号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>其美潮州鱼旦粉世家(惠福东分店)</td>\n",
       "      <td>B00141L0Z3</td>\n",
       "      <td>113.267760,23.121435</td>\n",
       "      <td>餐饮服务;中餐厅;潮州菜</td>\n",
       "      <td>050123</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路515号(近光明广场)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>捞起鲜食凉拌(北京路店)</td>\n",
       "      <td>B0HGCOILN7</td>\n",
       "      <td>113.268102,23.121433</td>\n",
       "      <td>餐饮服务;中餐厅;特色/地方风味餐厅</td>\n",
       "      <td>050118</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路525号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               name          id              location                type  \\\n",
       "0        阿婆牛杂(惠福东店)  B0H1LSGKB1  113.267923,23.121257        餐饮服务;中餐厅;中餐厅   \n",
       "1     五月的沙枣花抓饭(双河)店  B0HKLHRT20  113.268003,23.121231        餐饮服务;中餐厅;中餐厅   \n",
       "2      孖记一九九八(北京路店)  B0G2GMLXP4  113.267904,23.121165        餐饮服务;中餐厅;中餐厅   \n",
       "3           李喜欢手工虾滑  B0HRP55982  113.267803,23.121230        餐饮服务;中餐厅;中餐厅   \n",
       "4             牛骨牛杂屋  B0IGC7CRSP  113.267878,23.121375        餐饮服务;中餐厅;中餐厅   \n",
       "5      牛小灶牛杂煲(北京路店)  B0FFIS19MZ  113.268071,23.121263        餐饮服务;中餐厅;火锅店   \n",
       "6   火鳳祥鮮貨火锅商行(北京路店)  B0GK4AM0T3  113.268012,23.121408        餐饮服务;中餐厅;火锅店   \n",
       "7    蚝魁·高压锅生蚝·海鲜专门店  B0GKJAX5B6  113.268073,23.121416       餐饮服务;中餐厅;海鲜酒楼   \n",
       "8  其美潮州鱼旦粉世家(惠福东分店)  B00141L0Z3  113.267760,23.121435        餐饮服务;中餐厅;潮州菜   \n",
       "9      捞起鲜食凉拌(北京路店)  B0HGCOILN7  113.268102,23.121433  餐饮服务;中餐厅;特色/地方风味餐厅   \n",
       "\n",
       "  typecode pname cityname adname               address   pcode citycode  \\\n",
       "0   050100   广东省      广州市    越秀区         惠福东路564号101部位  440000      020   \n",
       "1   050100   广东省      广州市    越秀区        惠福东路568号(近北京路)  440000      020   \n",
       "2   050100   广东省      广州市    越秀区        惠福东路清源巷12号首、二层  440000      020   \n",
       "3   050100   广东省      广州市    越秀区           北京路惠福东路570号  440000      020   \n",
       "4   050100   广东省      广州市    越秀区      步行街与惠新西街交叉口东北20米  440000      020   \n",
       "5   050117   广东省      广州市    越秀区  北京路步行街惠福东美食街惠福东路586号  440000      020   \n",
       "6   050117   广东省      广州市    越秀区              惠福东路576号  440000      020   \n",
       "7   050119   广东省      广州市    越秀区              惠福东路515号  440000      020   \n",
       "8   050123   广东省      广州市    越秀区       惠福东路515号(近光明广场)  440000      020   \n",
       "9   050118   广东省      广州市    越秀区              惠福东路525号  440000      020   \n",
       "\n",
       "   adcode                                             photos  \n",
       "0  440104                                                NaN  \n",
       "1  440104                                                NaN  \n",
       "2  440104                                                NaN  \n",
       "3  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "4  440104                                                NaN  \n",
       "5  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "6  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "7  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "8  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "9  440104  [{'title': '', 'url': 'http://store.is.autonav...  "
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['pois'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3c8c75f",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89a3aa3f",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52251245",
   "metadata": {},
   "source": [
    "## 3.2 关键字——快餐厅"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "0946234d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块---关键字\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v5/place/text?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v5/place/text?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"keywords\" : \"广东省广州市越秀区北京路\",\n",
    "    \"show_fields\" : \"photos\",\n",
    "    \"types\": '050300'\n",
    "    \n",
    "    \n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fc062b3b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "f26ba85c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'name': '华莱士(北京路店)',\n",
       "   'id': 'B0H1YAX29B',\n",
       "   'location': '113.264398,23.123120',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '起义路172号地下(公园前地铁站J口步行180米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/d132e73f9df6df2a9643b7ed82789cff'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/6a04b40c5513f3d1e5637353ea7591ab'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/5bdfb1f66d610dc05fb93cb4785e3d6f'}]},\n",
       "  {'name': '胖老爹炸鸡',\n",
       "   'id': 'B0G17CYR77',\n",
       "   'location': '113.271719,23.122368',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '文德路67号金德大厦A1',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/3b991a3e053b0c54ab574e3953c33bb7'},\n",
       "    {'title': '',\n",
       "     'url': 'https://img.alicdn.com/imgextra/i3/3695320962/O1CN01q3Nukt1IydgzWJNHc_!!3695320962-0-kbcontentapng.jpg'},\n",
       "    {'title': '',\n",
       "     'url': 'https://img.alicdn.com/imgextra/i4/3695320962/O1CN0157mwLj1IydgrNQNif_!!3695320962-0-kbcontentapng.jpg'}]},\n",
       "  {'name': '大快活(北京路店)',\n",
       "   'id': 'B0G064LXFO',\n",
       "   'location': '113.269214,23.121317',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路188号(北京路地铁站B口步行380米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/d06713f90e62ce7190e24b2a5d99c550'},\n",
       "    {'title': '',\n",
       "     'url': 'https://img.alicdn.com/imgextra/i1/3695320962/O1CN01193Flf1IydiZrTyah_!!3695320962-0-kbcontentapng.jpg'},\n",
       "    {'title': '',\n",
       "     'url': 'https://img.alicdn.com/imgextra/i1/3695320962/O1CN01mO1ONz1IydieAJWOD_!!3695320962-0-kbcontentapng.jpg'}]},\n",
       "  {'name': '粿壹·鲜牛肉粿条汤(北京路店)',\n",
       "   'id': 'B0FFKPFS3U',\n",
       "   'location': '113.270058,23.122163',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '禺山路市场新街7号(天河城星巴克斜对面)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/46da079f96e4370fd858ba957d0d9aa3'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/155785d810fe1865bae2b21a4dfe2abb'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/1f0629ded5ca86672565b0b83c46ea93'}]},\n",
       "  {'name': '公仔堂港式茶餐厅(北京路店)',\n",
       "   'id': 'B0HBOXN9L7',\n",
       "   'location': '113.266609,23.126613',\n",
       "   'type': '餐饮服务;快餐厅;茶餐厅',\n",
       "   'typecode': '050305',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '广大路广大二巷21号首层(仅限办公用途)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/94df5b57da759797b8d36178b328d418'}]},\n",
       "  {'name': '汤饭(农讲店)',\n",
       "   'id': 'B0G076ZQFA',\n",
       "   'location': '113.274311,23.126679',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '中山四路128号(农讲所地铁站D口步行70米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/1fa2ae58fbb91534845e5d8c678b117f'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/40a12403ce292d90fe964a9a383de891'}]},\n",
       "  {'name': '2颗鸡蛋煎饼(北京路天河城店)',\n",
       "   'id': 'B0FFJOYTHU',\n",
       "   'location': '113.269947,23.119239',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路168号北京路天河城F1',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/0dad638a566082f197f0f0e2deb79b6a'},\n",
       "    {'title': '',\n",
       "     'url': 'https://img.alicdn.com/imgextra/i4/3695320962/O1CN011IydiWwS5RIs0vV_!!3695320962-0-kbcontentapng.jpg'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/ee5236af1aaba0c432557fdb137ce4ca'}]},\n",
       "  {'name': '撸小渔·老坛酸菜鱼',\n",
       "   'id': 'B0HU5DNMH4',\n",
       "   'location': '113.267366,23.121078',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '步行街与惠新西街交叉口西南40米',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/0771fc3a3d80b3166d650fd349d69310'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/62aef9c13b23c6f67f298efdb263d26c'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/65e0d89f564d7ed1d9800cc948c1ca8b'}]},\n",
       "  {'name': '中国兰州牛肉面',\n",
       "   'id': 'B0H1U91YHB',\n",
       "   'location': '113.277462,23.120901',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '越秀南路丽水坊小区(团一大广场地铁站A口步行300米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/5a36b6bb8a509be31f272cec490fada7'}]},\n",
       "  {'name': '生香食品店',\n",
       "   'id': 'B00141VVMX',\n",
       "   'location': '113.272457,23.118079',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '文德南路77号102房(北京路地铁站A口步行400米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/c54f778fb770ea12f5c279ac55b33afc'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/5172de7f26d6059e43635f3f2f5432f0'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/732b1cca55a8f7cd2e735c8ae9f0b254'}]}],\n",
       " 'count': '10'}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "3d7f7def",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "50bc4324",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>address</th>\n",
       "      <th>pcode</th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>photos</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>华莱士(北京路店)</td>\n",
       "      <td>B0H1YAX29B</td>\n",
       "      <td>113.264398,23.123120</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>起义路172号地下(公园前地铁站J口步行180米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>胖老爹炸鸡</td>\n",
       "      <td>B0G17CYR77</td>\n",
       "      <td>113.271719,23.122368</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>文德路67号金德大厦A1</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>大快活(北京路店)</td>\n",
       "      <td>B0G064LXFO</td>\n",
       "      <td>113.269214,23.121317</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路188号(北京路地铁站B口步行380米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>粿壹·鲜牛肉粿条汤(北京路店)</td>\n",
       "      <td>B0FFKPFS3U</td>\n",
       "      <td>113.270058,23.122163</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>禺山路市场新街7号(天河城星巴克斜对面)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>公仔堂港式茶餐厅(北京路店)</td>\n",
       "      <td>B0HBOXN9L7</td>\n",
       "      <td>113.266609,23.126613</td>\n",
       "      <td>餐饮服务;快餐厅;茶餐厅</td>\n",
       "      <td>050305</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>广大路广大二巷21号首层(仅限办公用途)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>汤饭(农讲店)</td>\n",
       "      <td>B0G076ZQFA</td>\n",
       "      <td>113.274311,23.126679</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>中山四路128号(农讲所地铁站D口步行70米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2颗鸡蛋煎饼(北京路天河城店)</td>\n",
       "      <td>B0FFJOYTHU</td>\n",
       "      <td>113.269947,23.119239</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路168号北京路天河城F1</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>撸小渔·老坛酸菜鱼</td>\n",
       "      <td>B0HU5DNMH4</td>\n",
       "      <td>113.267366,23.121078</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>步行街与惠新西街交叉口西南40米</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>中国兰州牛肉面</td>\n",
       "      <td>B0H1U91YHB</td>\n",
       "      <td>113.277462,23.120901</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>越秀南路丽水坊小区(团一大广场地铁站A口步行300米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>生香食品店</td>\n",
       "      <td>B00141VVMX</td>\n",
       "      <td>113.272457,23.118079</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>文德南路77号102房(北京路地铁站A口步行400米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              name          id              location          type typecode  \\\n",
       "0        华莱士(北京路店)  B0H1YAX29B  113.264398,23.123120  餐饮服务;快餐厅;快餐厅   050300   \n",
       "1            胖老爹炸鸡  B0G17CYR77  113.271719,23.122368  餐饮服务;快餐厅;快餐厅   050300   \n",
       "2        大快活(北京路店)  B0G064LXFO  113.269214,23.121317  餐饮服务;快餐厅;快餐厅   050300   \n",
       "3  粿壹·鲜牛肉粿条汤(北京路店)  B0FFKPFS3U  113.270058,23.122163  餐饮服务;快餐厅;快餐厅   050300   \n",
       "4   公仔堂港式茶餐厅(北京路店)  B0HBOXN9L7  113.266609,23.126613  餐饮服务;快餐厅;茶餐厅   050305   \n",
       "5          汤饭(农讲店)  B0G076ZQFA  113.274311,23.126679  餐饮服务;快餐厅;快餐厅   050300   \n",
       "6  2颗鸡蛋煎饼(北京路天河城店)  B0FFJOYTHU  113.269947,23.119239  餐饮服务;快餐厅;快餐厅   050300   \n",
       "7        撸小渔·老坛酸菜鱼  B0HU5DNMH4  113.267366,23.121078  餐饮服务;快餐厅;快餐厅   050300   \n",
       "8          中国兰州牛肉面  B0H1U91YHB  113.277462,23.120901  餐饮服务;快餐厅;快餐厅   050300   \n",
       "9            生香食品店  B00141VVMX  113.272457,23.118079  餐饮服务;快餐厅;快餐厅   050300   \n",
       "\n",
       "  pname cityname adname                      address   pcode citycode  adcode  \\\n",
       "0   广东省      广州市    越秀区    起义路172号地下(公园前地铁站J口步行180米)  440000      020  440104   \n",
       "1   广东省      广州市    越秀区                 文德路67号金德大厦A1  440000      020  440104   \n",
       "2   广东省      广州市    越秀区      北京路188号(北京路地铁站B口步行380米)  440000      020  440104   \n",
       "3   广东省      广州市    越秀区         禺山路市场新街7号(天河城星巴克斜对面)  440000      020  440104   \n",
       "4   广东省      广州市    越秀区         广大路广大二巷21号首层(仅限办公用途)  440000      020  440104   \n",
       "5   广东省      广州市    越秀区      中山四路128号(农讲所地铁站D口步行70米)  440000      020  440104   \n",
       "6   广东省      广州市    越秀区              北京路168号北京路天河城F1  440000      020  440104   \n",
       "7   广东省      广州市    越秀区             步行街与惠新西街交叉口西南40米  440000      020  440104   \n",
       "8   广东省      广州市    越秀区  越秀南路丽水坊小区(团一大广场地铁站A口步行300米)  440000      020  440104   \n",
       "9   广东省      广州市    越秀区  文德南路77号102房(北京路地铁站A口步行400米)  440000      020  440104   \n",
       "\n",
       "                                              photos  \n",
       "0  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "1  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "2  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "3  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "4  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "5  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "6  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "7  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "8  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "9  [{'title': '', 'url': 'http://store.is.autonav...  "
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['pois'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "436705c4",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8ce421e",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1fb95cf",
   "metadata": {},
   "source": [
    "## 3.3 多边形区域搜索——外国餐厅"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "8a46f757",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块（google chrome 浏览器）---多边形\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v5/place/polygon?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v5/place/polygon?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"polygon\" : \"113.274311,23.126679|113.267366,23.121078|113.277462,23.120901\",\n",
    "    \"types\" : \"050200\",\n",
    "    \"show_fields\" : \"photos\"\n",
    "    \n",
    "    \n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "dab74d4b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "ba68a7d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'name': '壹玄食堂日料居酒屋(北京路店)',\n",
       "   'id': 'B0FFJWFVW9',\n",
       "   'location': '113.273675,23.123536',\n",
       "   'type': '餐饮服务;外国餐厅;日本料理',\n",
       "   'typecode': '050202',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '文明路115号骏文雅苑101-4',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/264ac2398fccb0ce728ba57c9a34080f'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/777ab07400dd8f46fda56cc025b5977d'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/124276e4c9d2e49171fe9cd16d9e539e'}]},\n",
       "  {'name': '藤田将太日本料理(文徳店)',\n",
       "   'id': 'B0FFJ8LYQV',\n",
       "   'location': '113.272095,23.123452',\n",
       "   'type': '餐饮服务;外国餐厅;外国餐厅',\n",
       "   'typecode': '050200',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '东方文德广场',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/488c12257dc9530869e243e3130b31db'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/12cb98cefbf5976b98acb78ac42a2e2b'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/1cf4fc603a1699156a1f1f416276b55d'}]},\n",
       "  {'name': '越名轩(北京路店)',\n",
       "   'id': 'B0FFISGR2K',\n",
       "   'location': '113.267931,23.121383',\n",
       "   'type': '餐饮服务;外国餐厅;其它亚洲菜',\n",
       "   'typecode': '050217',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路惠福东路509号表少茶餐厅旁',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/67aade6581d8e593486d79e142f27572'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/72051069d77f13ee2a1a40de685b4bbf'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/f35a7d8c281508726e950dee49081d9a'}]},\n",
       "  {'name': '颖丰泰国菜馆(惠福东路店)',\n",
       "   'id': 'B00140ARIK',\n",
       "   'location': '113.268635,23.121554',\n",
       "   'type': '餐饮服务;外国餐厅;泰国/越南菜品餐厅',\n",
       "   'typecode': '050206',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路529号(北京路地铁站B口步行450米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/8beae3d7d1583a511d46f5feb24a305e'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/35ad39593c8b954d7ec04b6e8183b1be'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/559e15eca3106b2e550da01a'}]},\n",
       "  {'name': '网红居酒屋·匠人寿司(北京路步行街店)',\n",
       "   'id': 'B0FFL6AWLR',\n",
       "   'location': '113.267607,23.121085',\n",
       "   'type': '餐饮服务;外国餐厅;日本料理',\n",
       "   'typecode': '050202',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路558号嬷嬷牛肉店隔壁',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/f65be33a3e53406c94030df0a873f19b'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/fc68f00dd93b4aec8ac5413c82804475'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/ed6dd9583f704657a5beff8693fd9380'}]},\n",
       "  {'name': '金顺碳烤肉(北京路店)',\n",
       "   'id': 'B0H107X8HP',\n",
       "   'location': '113.269465,23.121664',\n",
       "   'type': '餐饮服务;外国餐厅;韩国料理',\n",
       "   'typecode': '050203',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '禺山路21号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/cff222d91430a1dae0238981f7acffed'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/1134d0ca78c97c59676c4406acb2725a'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/213621d7365fd9137c9a5434e0af69f2'}]},\n",
       "  {'name': '达美乐比萨(文德北路店)',\n",
       "   'id': 'B0HA17FX2D',\n",
       "   'location': '113.271774,23.123572',\n",
       "   'type': '餐饮服务;外国餐厅;外国餐厅',\n",
       "   'typecode': '050200',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '文德北路68号东方文德广场首层中庭',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/e8820adf33658db461a1136553b9ca4d'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/1aa34c59b1400fd0d32fd101ed90ebb6'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/69799397fe5d51df16e32e1cb3f5d105'}]},\n",
       "  {'name': '萨莉亚意式餐厅(046北京路天河城店)',\n",
       "   'id': 'B0FFJN6WPT',\n",
       "   'location': '113.270271,23.123117',\n",
       "   'type': '餐饮服务;外国餐厅;意式菜品餐厅',\n",
       "   'typecode': '050205',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路238号天河城百货7楼',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/05f6ffc4ba1a1485d66c190b69004379'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/99893da1e53685b3a84c76820c86f3bf'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/088de893b9938ad9525c8f55d94763fa'}]},\n",
       "  {'name': '泰盏鬼·颓废冬阴(北京路二店)',\n",
       "   'id': 'B0H1KL482E',\n",
       "   'location': '113.269869,23.121779',\n",
       "   'type': '餐饮服务;外国餐厅;泰国/越南菜品餐厅',\n",
       "   'typecode': '050206',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '禺山路与北京路交叉口东80米',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/3c19bc6648773f1a209ebb8506f3a863'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/2492ee4aae8747a4b9879149d53537ed'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/6ce5e04ab096d255c6151106c095a75e'}]},\n",
       "  {'name': '大众食堂韩国料理',\n",
       "   'id': 'B0GRYASMFD',\n",
       "   'location': '113.268395,23.121475',\n",
       "   'type': '餐饮服务;外国餐厅;韩国料理',\n",
       "   'typecode': '050203',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路527号(北京路地铁站B口步行480米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104',\n",
       "   'photos': [{'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/37053130387d628326d8571b3fddb114'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/95dc8bb85419b38358c6afe5160195af'},\n",
       "    {'title': '',\n",
       "     'url': 'http://store.is.autonavi.com/showpic/6dcf60fe9fe71550d4d742bdb055c2a0'}]}],\n",
       " 'count': '10'}"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "d8029fcb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "1e814cbc",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>address</th>\n",
       "      <th>pcode</th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>photos</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>壹玄食堂日料居酒屋(北京路店)</td>\n",
       "      <td>B0FFJWFVW9</td>\n",
       "      <td>113.273675,23.123536</td>\n",
       "      <td>餐饮服务;外国餐厅;日本料理</td>\n",
       "      <td>050202</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>文明路115号骏文雅苑101-4</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>藤田将太日本料理(文徳店)</td>\n",
       "      <td>B0FFJ8LYQV</td>\n",
       "      <td>113.272095,23.123452</td>\n",
       "      <td>餐饮服务;外国餐厅;外国餐厅</td>\n",
       "      <td>050200</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>东方文德广场</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>越名轩(北京路店)</td>\n",
       "      <td>B0FFISGR2K</td>\n",
       "      <td>113.267931,23.121383</td>\n",
       "      <td>餐饮服务;外国餐厅;其它亚洲菜</td>\n",
       "      <td>050217</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路惠福东路509号表少茶餐厅旁</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>颖丰泰国菜馆(惠福东路店)</td>\n",
       "      <td>B00140ARIK</td>\n",
       "      <td>113.268635,23.121554</td>\n",
       "      <td>餐饮服务;外国餐厅;泰国/越南菜品餐厅</td>\n",
       "      <td>050206</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路529号(北京路地铁站B口步行450米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>网红居酒屋·匠人寿司(北京路步行街店)</td>\n",
       "      <td>B0FFL6AWLR</td>\n",
       "      <td>113.267607,23.121085</td>\n",
       "      <td>餐饮服务;外国餐厅;日本料理</td>\n",
       "      <td>050202</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路558号嬷嬷牛肉店隔壁</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>金顺碳烤肉(北京路店)</td>\n",
       "      <td>B0H107X8HP</td>\n",
       "      <td>113.269465,23.121664</td>\n",
       "      <td>餐饮服务;外国餐厅;韩国料理</td>\n",
       "      <td>050203</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>禺山路21号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>达美乐比萨(文德北路店)</td>\n",
       "      <td>B0HA17FX2D</td>\n",
       "      <td>113.271774,23.123572</td>\n",
       "      <td>餐饮服务;外国餐厅;外国餐厅</td>\n",
       "      <td>050200</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>文德北路68号东方文德广场首层中庭</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>萨莉亚意式餐厅(046北京路天河城店)</td>\n",
       "      <td>B0FFJN6WPT</td>\n",
       "      <td>113.270271,23.123117</td>\n",
       "      <td>餐饮服务;外国餐厅;意式菜品餐厅</td>\n",
       "      <td>050205</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路238号天河城百货7楼</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>泰盏鬼·颓废冬阴(北京路二店)</td>\n",
       "      <td>B0H1KL482E</td>\n",
       "      <td>113.269869,23.121779</td>\n",
       "      <td>餐饮服务;外国餐厅;泰国/越南菜品餐厅</td>\n",
       "      <td>050206</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>禺山路与北京路交叉口东80米</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>大众食堂韩国料理</td>\n",
       "      <td>B0GRYASMFD</td>\n",
       "      <td>113.268395,23.121475</td>\n",
       "      <td>餐饮服务;外国餐厅;韩国料理</td>\n",
       "      <td>050203</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路527号(北京路地铁站B口步行480米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "      <td>[{'title': '', 'url': 'http://store.is.autonav...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  name          id              location                 type  \\\n",
       "0      壹玄食堂日料居酒屋(北京路店)  B0FFJWFVW9  113.273675,23.123536       餐饮服务;外国餐厅;日本料理   \n",
       "1        藤田将太日本料理(文徳店)  B0FFJ8LYQV  113.272095,23.123452       餐饮服务;外国餐厅;外国餐厅   \n",
       "2            越名轩(北京路店)  B0FFISGR2K  113.267931,23.121383      餐饮服务;外国餐厅;其它亚洲菜   \n",
       "3        颖丰泰国菜馆(惠福东路店)  B00140ARIK  113.268635,23.121554  餐饮服务;外国餐厅;泰国/越南菜品餐厅   \n",
       "4  网红居酒屋·匠人寿司(北京路步行街店)  B0FFL6AWLR  113.267607,23.121085       餐饮服务;外国餐厅;日本料理   \n",
       "5          金顺碳烤肉(北京路店)  B0H107X8HP  113.269465,23.121664       餐饮服务;外国餐厅;韩国料理   \n",
       "6         达美乐比萨(文德北路店)  B0HA17FX2D  113.271774,23.123572       餐饮服务;外国餐厅;外国餐厅   \n",
       "7  萨莉亚意式餐厅(046北京路天河城店)  B0FFJN6WPT  113.270271,23.123117     餐饮服务;外国餐厅;意式菜品餐厅   \n",
       "8      泰盏鬼·颓废冬阴(北京路二店)  B0H1KL482E  113.269869,23.121779  餐饮服务;外国餐厅;泰国/越南菜品餐厅   \n",
       "9             大众食堂韩国料理  B0GRYASMFD  113.268395,23.121475       餐饮服务;外国餐厅;韩国料理   \n",
       "\n",
       "  typecode pname cityname adname                   address   pcode citycode  \\\n",
       "0   050202   广东省      广州市    越秀区          文明路115号骏文雅苑101-4  440000      020   \n",
       "1   050200   广东省      广州市    越秀区                    东方文德广场  440000      020   \n",
       "2   050217   广东省      广州市    越秀区         北京路惠福东路509号表少茶餐厅旁  440000      020   \n",
       "3   050206   广东省      广州市    越秀区  惠福东路529号(北京路地铁站B口步行450米)  440000      020   \n",
       "4   050202   广东省      广州市    越秀区           惠福东路558号嬷嬷牛肉店隔壁  440000      020   \n",
       "5   050203   广东省      广州市    越秀区                    禺山路21号  440000      020   \n",
       "6   050200   广东省      广州市    越秀区         文德北路68号东方文德广场首层中庭  440000      020   \n",
       "7   050205   广东省      广州市    越秀区            北京路238号天河城百货7楼  440000      020   \n",
       "8   050206   广东省      广州市    越秀区            禺山路与北京路交叉口东80米  440000      020   \n",
       "9   050203   广东省      广州市    越秀区  惠福东路527号(北京路地铁站B口步行480米)  440000      020   \n",
       "\n",
       "   adcode                                             photos  \n",
       "0  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "1  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "2  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "3  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "4  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "5  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "6  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "7  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "8  440104  [{'title': '', 'url': 'http://store.is.autonav...  \n",
       "9  440104  [{'title': '', 'url': 'http://store.is.autonav...  "
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['pois'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3f4c5da",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83622858",
   "metadata": {},
   "source": [
    "&emsp;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6400b91",
   "metadata": {},
   "source": [
    "## 3.4 id搜索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "cbd8981a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块---id\n",
    "import requests\n",
    "# 2. 请求方法 ： GET\n",
    "# 3. URL地址 ： https://restapi.amap.com/v5/place/detail?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v5/place/detail?parameters\"\n",
    "# 4. 准备参数，用于交换数据 payload\n",
    "payload = {\n",
    "    \"key\": api_s,\n",
    "    \"id\": 'B0H1YAX29B|B0G17CYR77|B00141L0Z3|B0FFIS19MZ',\n",
    "    \n",
    "    \n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "b6c73c95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "127f68d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'name': '华莱士(北京路店)',\n",
       "   'id': 'B0H1YAX29B',\n",
       "   'location': '113.264398,23.123120',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '起义路172号地下(公园前地铁站J口步行180米)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '胖老爹炸鸡',\n",
       "   'id': 'B0G17CYR77',\n",
       "   'location': '113.271719,23.122368',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'typecode': '050300',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '文德路67号金德大厦A1',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '其美潮州鱼旦粉世家(惠福东分店)',\n",
       "   'id': 'B00141L0Z3',\n",
       "   'location': '113.267760,23.121435',\n",
       "   'type': '餐饮服务;中餐厅;潮州菜',\n",
       "   'typecode': '050123',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '惠福东路515号(近光明广场)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'},\n",
       "  {'name': '牛小灶牛杂煲(北京路店)',\n",
       "   'id': 'B0FFIS19MZ',\n",
       "   'location': '113.268071,23.121263',\n",
       "   'type': '餐饮服务;中餐厅;火锅店',\n",
       "   'typecode': '050117',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '越秀区',\n",
       "   'address': '北京路步行街惠福东美食街惠福东路586号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440104'}],\n",
       " 'count': '4'}"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "5d829a49",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "b614c22c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>address</th>\n",
       "      <th>pcode</th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>华莱士(北京路店)</td>\n",
       "      <td>B0H1YAX29B</td>\n",
       "      <td>113.264398,23.123120</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>起义路172号地下(公园前地铁站J口步行180米)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>胖老爹炸鸡</td>\n",
       "      <td>B0G17CYR77</td>\n",
       "      <td>113.271719,23.122368</td>\n",
       "      <td>餐饮服务;快餐厅;快餐厅</td>\n",
       "      <td>050300</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>文德路67号金德大厦A1</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>其美潮州鱼旦粉世家(惠福东分店)</td>\n",
       "      <td>B00141L0Z3</td>\n",
       "      <td>113.267760,23.121435</td>\n",
       "      <td>餐饮服务;中餐厅;潮州菜</td>\n",
       "      <td>050123</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>惠福东路515号(近光明广场)</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>牛小灶牛杂煲(北京路店)</td>\n",
       "      <td>B0FFIS19MZ</td>\n",
       "      <td>113.268071,23.121263</td>\n",
       "      <td>餐饮服务;中餐厅;火锅店</td>\n",
       "      <td>050117</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>北京路步行街惠福东美食街惠福东路586号</td>\n",
       "      <td>440000</td>\n",
       "      <td>020</td>\n",
       "      <td>440104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               name          id              location          type typecode  \\\n",
       "0         华莱士(北京路店)  B0H1YAX29B  113.264398,23.123120  餐饮服务;快餐厅;快餐厅   050300   \n",
       "1             胖老爹炸鸡  B0G17CYR77  113.271719,23.122368  餐饮服务;快餐厅;快餐厅   050300   \n",
       "2  其美潮州鱼旦粉世家(惠福东分店)  B00141L0Z3  113.267760,23.121435  餐饮服务;中餐厅;潮州菜   050123   \n",
       "3      牛小灶牛杂煲(北京路店)  B0FFIS19MZ  113.268071,23.121263  餐饮服务;中餐厅;火锅店   050117   \n",
       "\n",
       "  pname cityname adname                    address   pcode citycode  adcode  \n",
       "0   广东省      广州市    越秀区  起义路172号地下(公园前地铁站J口步行180米)  440000      020  440104  \n",
       "1   广东省      广州市    越秀区               文德路67号金德大厦A1  440000      020  440104  \n",
       "2   广东省      广州市    越秀区            惠福东路515号(近光明广场)  440000      020  440104  \n",
       "3   广东省      广州市    越秀区       北京路步行街惠福东美食街惠福东路586号  440000      020  440104  "
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['pois'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7f474a5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
